#include <iostream>
#include <deque>
using namespace std;

class TextEditor
{
    deque<char> textPrefix;
    deque<char> textSuffix;

public:
    TextEditor()
    {
    }

    void addText(string text)
    {
        for (auto c : text)
            textPrefix.push_back(c);
    }

    int deleteText(int k)
    {
        int dc = min(k, (int)textPrefix.size());
        while (k-- && !textPrefix.empty())
            textPrefix.pop_back();
        return dc;
    }

    string cursorLeft(int k)
    {
        while (k-- && !textPrefix.empty())
        {
            textSuffix.push_front(textPrefix.back());
            textPrefix.pop_back();
        }
        return string(textPrefix.end() - min(static_cast<size_t>(10), textPrefix.size()), textPrefix.end());
    }

    string cursorRight(int k)
    {
        while (k-- && !textSuffix.empty())
        {
            textPrefix.push_back(textSuffix.front());
            textSuffix.pop_front();
        }
        return string(textPrefix.end() - min(static_cast<size_t>(10), textPrefix.size()), textPrefix.end());
    }
};

int main()
{
    cout << "Code2296" << endl;
    TextEditor editor;
    editor.addText("leetcode");
    editor.deleteText(4);
    editor.addText("practice");
    editor.cursorRight(3);
    return 0;
}